package com.wy._02io.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 可能是文件关系的枚举
 */
public enum PITFHEnum {
    DISTANCE_0(0),
    DISTANCE_1(1),
    DISTANCE_2(2),
    DISTANCE__1(-1);

    private final int distance;
    private static final Map<Integer, PITFHEnum> valueMap = new HashMap<>();

    static {
        for (PITFHEnum type : values()) {
            valueMap.put(type.distance, type);
        }
    }

    PITFHEnum(int distance) {
        this.distance = distance;
    }

    public int getDistance() {
        return distance;
    }

    public static List<PITFHEnum> getDistances(int... distances) {
        List<PITFHEnum> pitfhEnums = new ArrayList<>();
        for (int distance : distances) {
            PITFHEnum pitfhEnum = valueMap.getOrDefault(distance, DISTANCE__1);
            pitfhEnums.add(pitfhEnum);
        }
        return pitfhEnums;
    }
}